package felix.dataviewer.View;

import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

import felix.dataviewer.R;
import felix.felixlib.Base.BaseAty;
import felix.felixlib.Base.BaseFg;
import felix.felixlib.Base.adp.FgPagerAdp;
import felix.felixlib.annotation.BindLayout;
import felix.felixlib.annotation.BindView;

@BindLayout(R.layout.aty_main)
public class MainAty extends BaseAty {

    @BindView(R.id.vp_data)
    ViewPager mVpData;
    private List<BaseFg> mBaseFgs;
    private FgPagerAdp mFgPagerAdp;

    @Override
    protected void initData() {
        super.initData();
        mBaseFgs = new ArrayList<>();
        mBaseFgs.add(new MainFg());
        mFgPagerAdp = new FgPagerAdp(mContext, getFragmentManager(), mBaseFgs);
        mVpData.setAdapter(mFgPagerAdp);
    }

    private <FG extends BaseFg> void addFg(FG fg) {
        mBaseFgs.add(fg);
        mFgPagerAdp.notifyDataSetChanged();
    }
}
